package com.summer.study.leetcode.recursion;


/**
 * @auther: 杨杰
 * @date: 2019/7/29 16:50
 * @description: 递归
 */
public class Recursion {

    private static int add(int num) {
        if (num == 1) {
            return 1;
        }
        return num + add(num - 1);
    }

    /**
     * @param num :
     * @auther:   杨杰
     * @date:     2019/7/30 9:16
     * @description 阶乘 5*4*3*2*1
     */
    private static int factorial(int num) {
        if (num == 1) {
            return 1;
        }
        return num * factorial(num - 1);
    }




    public static void main(String[] args) {
        System.out.println(add(100));
        System.out.println(factorial(6));
        int[] nums=new int[]{2,2,1,1,1,2,2};
    }
}
